package com.df.springmvc.common.bean;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class DhtmlxGantBean{
	public final static String link_finish_to_finish="2";
	public final static String link_finish_to_start="0";
	public final static String link_start_to_finish="3";
	public final static String link_start_to_start="1";
	ArrayList<Data> data=new ArrayList<Data>();
	Collections collections=new Collections();
	
	/**
	 * @param id
	 *            任务编号
	 * @param start_date
	 *            开始时间
	 * @param duration
	 *            步长
	 * @param text
	 *            标题
	 * @param progress
	 *            进度 (小数)
	 * @param sortorder
	 *            排序 int
	 * @param parent
	 *            上级任务编号 最上层为0
	 * @param open
	 *            是否开启 boolean
	 */
	public void addData(String id,Date start_date,int duration,String text,double progress,int sortorder,String parent,boolean open){
		data.add(new Data(id,start_date,duration,text,progress,sortorder,parent,open));
	}
	/**
	 * @param id
	 *            任务编号
	 * @param start_date
	 *            开始时间
	 * @param duration
	 *            步长
	 * @param text
	 *            标题
	 * @param progress
	 *            进度 (小数)
	 * @param sortorder
	 *            排序 int
	 * @param parent
	 *            上级任务编号 最上层为0
	 * @param open
	 *            是否开启 boolean
	 * @param splitStart
	 *            分离开始
	 * @param splitEnd
	 *            分离结束
	 */
	public void addData(String id,Date start_date,int duration,String text,double progress,int sortorder,String parent,boolean open,int splitStart,int splitEnd){
		data.add(new Data(id,start_date,duration,text,progress,sortorder,parent,open,splitStart,splitEnd));
	}
	public void addData(Data data_){
		data.add(data_);
	}
	public void addLink(Link link){
		collections.getLinks().add(link);
	}
	/**
	 * @param id
	 * @param source
	 * @param target
	 * @param type
	 */
	public void addLink(String id,String source,String target,String type){
		collections.getLinks().add(new Link(id,source,target,type));
	}
	public ArrayList<Data> getData(){
		return data;
	}
	public void setData(ArrayList<Data> data){
		this.data=data;
	}
	public Collections getCollections(){
		return collections;
	}
	public void setCollections(Collections collections){
		this.collections=collections;
	}
}
class Data{
	String id;
	String start_date;
	int duration;
	String text;
	double progress;
	int sortorder;
	String parent;
	Boolean open=true;
	int splitStart;
	int splitEnd;
	
	/**
	 * @param id
	 * @param start_date
	 * @param duration
	 * @param text
	 * @param progress
	 * @param sortorder
	 * @param parent
	 * @param open
	 */
	public Data(String id,Date start_date,int duration,String text,double progress,int sortorder,String parent,boolean open){
		// TODO Auto-generated constructor stub
		setId(id);
		setStart_date(start_date);
		setDuration(duration);
		setText(text);
		setProgress(progress);
		setSortorder(sortorder);
		setParent(parent);
		setOpen(open);
	}
	/**
	 * @param id
	 * @param start_date
	 * @param duration
	 * @param text
	 * @param progress
	 * @param sortorder
	 * @param parent
	 * @param open
	 * @param splitStart
	 * @param splitEnd
	 */
	public Data(String id,Date start_date,int duration,String text,double progress,int sortorder,String parent,boolean open,int splitStart,int splitEnd){
		// TODO Auto-generated constructor stub
		new Data(id,start_date,duration,text,progress,sortorder,parent,open);
		setSplitStart(splitStart);
		setSplitEnd(splitEnd);
	}
	public String getId(){
		return id;
	}
	public void setId(String id){
		this.id=id;
	}
	public String getStart_date(){
		return start_date;
	}
	public void setStart_date(Date start_date){
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		this.start_date=sdf.format(start_date);
	}
	public void setStart_date(String start_date){
		this.start_date=start_date;
	}
	public int getDuration(){
		return duration;
	}
	public void setDuration(int duration){
		this.duration=duration;
	}
	public String getText(){
		return text;
	}
	public void setText(String text){
		this.text=text;
	}
	public double getProgress(){
		return progress;
	}
	public void setProgress(double progress){
		this.progress=progress;
	}
	public int getSortorder(){
		return sortorder;
	}
	public void setSortorder(int sortorder){
		this.sortorder=sortorder;
	}
	public String getParent(){
		return parent;
	}
	public void setParent(String parent){
		this.parent=parent;
	}
	public Boolean getOpen(){
		return open;
	}
	public void setOpen(Boolean open){
		this.open=open;
	}
	public int getSplitStart(){
		return splitStart;
	}
	public void setSplitStart(int splitStart){
		this.splitStart=splitStart;
	}
	public int getSplitEnd(){
		return splitEnd;
	}
	public void setSplitEnd(int splitEnd){
		this.splitEnd=splitEnd;
	}
}
/**
 * "id": 1,
 * "source": 1,
 * "target": 2,
 * "type": "0"
 * @author David
 */
class Link{
	String id;
	String source;
	String target;
	String type;
	
	/**
	 * @param id
	 * @param source
	 * @param target
	 * @param type
	 */
	public Link(String id,String source,String target,String type){
		// TODO Auto-generated constructor stub
		setId(id);
		setSource(source);
		setTarget(target);
		setType(type);
	}
	public String getId(){
		return id;
	}
	public void setId(String id){
		this.id=id;
	}
	public String getSource(){
		return source;
	}
	public void setSource(String source){
		this.source=source;
	}
	public String getTarget(){
		return target;
	}
	public void setTarget(String target){
		this.target=target;
	}
	public String getType(){
		return type;
	}
	public void setType(String type){
		this.type=type;
	}
}
class Collections{
	ArrayList<Link> links=new ArrayList<Link>();
	
	public ArrayList<Link> getLinks(){
		return links;
	}
	public void setLinks(ArrayList<Link> links){
		this.links=links;
	}
}
